<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .p01{
            width:200px;
            height:100px;
            background-color:green;
        }
    </style>
</head>

<body>
    <div id="box">

    </div>
  
    <script src="./js/react18.js"></script>
    <script src="./js/react-dom18.js"></script>
    <script src="./js/babel.min.js"></script>
    
    <script type="text/babel">

        // 创建一个根对象：
        let root = ReactDOM.createRoot(document.getElementById("box"));

        // 这是一个jsx的数组。jsx数组可以直接在jsx上渲染
        const books=[
            <li>三国演义</li>,
            <li>红楼梦</li>,
            <li>西游记</li>,
        ]

        const persons = ["范旭康","刘梁涛","吕超"];
        const personsJSX = persons.map((item,index)=>(<li key={index}>{item}</li>));
       
        const jsx = (<div>
                        <h2>标题2：</h2>
                        <p>书籍列表：</p>
                        <ul>
                        {/*jsx数组可以直接在jsx上渲染*/}
                        {books}
                        </ul>
                        <p>人物列表：</p>
                        <ul>
                            {personsJSX}
                        </ul>
                        <p>人物列表：</p>
                        <ul>
                            {persons.map(item=>(<li>{item}</li>))}
                        </ul>
                    </div>);
        
        console.log("jsx",jsx);//jsx就是虚拟dom


        // 把jsx渲染到根对象对应的dom容器里
        root.render(jsx);
        

    </script>
</body>

</html>